var statusCheckObj = {
    userid: "",
    init: function(et) {
        this.userid = $.cookie('userid');
        this.getGroupInfor(et);
    },
    getGroupInfor: function(et) {
        var me = this;
        var url = magic_config.urlPrefix + 'GroupbuyService/getallgroupbuyinfo';
        var sUserIdStr;
        if (me.userid == null) {
            sUserIdStr = "";
        } else {
            sUserIdStr = me.userid;
        }
        var data = {
            lTeamId: publicObj.getUrlData("lTeamId"),
            sUserId: sUserIdStr
        }
        $.ajax({
            url: url,
            type: 'get',
            data: data,
            async: false,
            dataType: 'json',
            success: function(res) {
                var nCode = res.return.nCode;
                if (nCode === 0) {
                    if (et == 1) {
                        me.judeStatus(res.response);
                    } else {
                        me.loginStatus(res.response);
                    }

                } else {
                    console.log("数据请求失败，后到前");
                }
            },
            error: function(res) {
                console.log("数据请求失败，前到后");
            }
        });
    },
    judeStatus: function(resObj) {
        /*1.拼团成功
            a.用户参与了团购
            b.用户未参与团购
          2.拼团失败
            a.拼团失败
          3.团进行中
            a.参与团，走支付流程
                - 用户已支付
                - 用户未支付
        */
        var joinFlage = resObj.isJoinTream;
        var gStatus = resObj.cdoTreamInfo.nStatus;
        var oStatus = resObj.cdoOrderData.nStatus;
        // gStatus = 2;
        // joinFlage = true;
        console.log(joinFlage, gStatus, oStatus);
        if (gStatus == 9 || gStatus == 10) {
            location.replace('./gfail.html?lTeamId=' + publicObj.getUrlData("lTeamId"))
        } else if (gStatus == 2) {
            if (joinFlage) {
                location.replace('./gsuc.html?lTeamId=' + publicObj.getUrlData("lTeamId"))
            } else {
                location.replace('./gfull.html?lTeamId=' + publicObj.getUrlData("lTeamId"))
            }
        } else {
            if (oStatus == 1) {
                location.replace('./gGroup.html?lTeamId=' + publicObj.getUrlData("lTeamId"))
            } else {
                location.replace('./pay.html?lTeamId=' + publicObj.getUrlData("lTeamId"))
            }

        }
    },
    loginStatus: function(resObj) {
        var joinFlage = resObj.isJoinTream;
        var gStatus = resObj.cdoTreamInfo.nStatus;
        var oStatus = resObj.cdoOrderData.nStatus;
        // gStatus = 2;
        // joinFlage = true;
        console.log(joinFlage, gStatus, oStatus);
        if (gStatus == 9) {
            location.href = './gfail.html?lTeamId=' + publicObj.getUrlData("lTeamId");
        } else if (gStatus == 2) {
            if (joinFlage) {
                location.href = './gsuc.html?lTeamId=' + publicObj.getUrlData("lTeamId");
            } else {
                location.href = './gfull.html?lTeamId=' + publicObj.getUrlData("lTeamId");
            }
        } else {
            if (oStatus == 1) {
                location.href = './gGroup.html?lTeamId=' + publicObj.getUrlData("lTeamId");
            } else {
                location.href = './index.html?lTeamId=' + publicObj.getUrlData("lTeamId") + '&openId=' + sessionStorage.getItem("openId")+'&flage=1';
            }

        }
    }
};